'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, STRING, DATE,TEXT } = Sequelize;
    await queryInterface.createTable("sys_oper_log", {
      oper_id: {
        type: INTEGER(20),
        comment: "日志主键",
        allowNull: false,
        primaryKey: true,
        autoIncrement: true
      },
      title:{
        type:STRING(50),
        comment:"模块标题",
        defaultValue:""
      },
      business_type:{
        type:STRING(1),
        comment:"业务类型（0其它 1新增 2修改 3删除）",
        defaultValue:"0"
      },
      method:{
        type:STRING(100),
        comment:"方法名称",
        defaultValue:""
      },
      request_method:{
        type:STRING(10),
        comment:"请求方式",
        defaultValue:""
      },
      operator_type:{
        type:STRING(1),
        comment:"操作类别（0其它 1后台用户 2手机端用户）",
        defaultValue:"0"
      },
      oper_name:{
        type:STRING(50),
        comment:"操作人员",
        defaultValue:""
      },
      dept_name:{
        type:STRING(50),
        comment:"部门名称",
        defaultValue:""
      },
      oper_url:{
        type:STRING(255),
        comment:"请求URL",
        defaultValue:""
      },
      oper_ip:{
        type:STRING(128),
        comment:"主机地址",
        defaultValue:""
      },
      oper_location:{
        type:STRING(255),
        comment:"操作地点"
      },
      oper_param:{
        type:TEXT,
        comment:"请求参数"
      },
      json_result:{
        type:TEXT,
        comment:"返回参数"
      },
      status:{
        type:STRING(1),
        comment:"操作状态（0正常 1异常）",
        defaultValue:"0"
      },
      error_msg:{
        type:TEXT,
        comment:"错误消息",
        defaultValue:""
      },
      oper_time:{
        type:DATE,
        comment:"操作时间",
        defaultValue:Sequelize.NOW
      },
      created_at: {
        type: DATE,
        comment: "创建时间",
      },
      updated_at: {
        type: DATE,
        comment: "更新时间",
      },
      deleted_at: {
        type: DATE,
        comment: "删除时间",
      }
    })
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('sys_oper_log');
     */
     await queryInterface.dropTable('sys_oper_log');
  }
};
